﻿/*
 * 树，无线循环列表
 * item 基类
 * 
 */
using System;
using UnityEngine;
using UnityEngine.UI;

namespace SuperScrollView
{
    public class SuperTreeBaseItem : MonoBehaviour
    {
        public enum SuperTreeItemType
        {
            Tree,
            Child
        }
        public Button mBtn;
        public SuperTreeItemType mType;
        Action<SuperTreeBaseItem> mClickHandler;
        Action<SuperTreeBaseItem> mShowHandler;

        public virtual void Init()
        {
            if (mBtn != null)
            {
                mBtn.onClick.AddListener(OnButtonClicked);
            }
        }
        public int TreeItemType
        {
            get { return (int)mType; }
        }

        void OnButtonClicked()
        {
            mClickHandler?.Invoke(this);
        }

        public void OnClickSelect(Action<SuperTreeBaseItem> clickHandler)
        {
            mClickHandler = clickHandler;
        }
        public void OnItemShow(Action<SuperTreeBaseItem> showHandler)
        {
            mShowHandler = showHandler;
        }

        public void RefreshItem()
        {
            mShowHandler?.Invoke(this);
        }
    }
}


